package ao.com.bna.beans;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * The persistent class for the auth_operador database table.
 * 
 */
@Entity
@Table(name = "AuthUtilizador")
@NamedQueries({
		@NamedQuery(name = "AuthUtilizador.findByLogin", query = "SELECT e FROM AuthUtilizador e WHERE e.username = :username") })
public class AuthUtilizador implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@SequenceGenerator(name = "AUTHUTILIZADOR_ID_GENERATOR", sequenceName = "AUTHUTILIZADOR_SEQ", allocationSize = 1)
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "AUTHUTILIZADOR_ID_GENERATOR")
	@Column(nullable = false, precision = 6)
	private Long id;
	// @org.hibernate.annotations.NaturalId
	@Column(nullable = false, unique = true, length = 20)
	private String username;
	@Basic(optional = false)
	@Column(nullable = false, length = 50)
	private String password;
	private boolean activo;
	@Basic(optional = false)
	@Column(nullable = false, length = 100)
	private String nome;
	private Integer telefone;
	private Integer extensao;
	private Integer fax;
	@Basic(optional = true)
	@Column(nullable = true, length = 100)
	private String email;
	@Temporal(TemporalType.TIMESTAMP)
	private Date dataRegisto;
	// private Long operadorRegisto;
	@Temporal(TemporalType.TIMESTAMP)
	private Date dataAlteracao;
	// private Long operadorAlteracao;
	@ManyToOne(optional = false)
	@JoinColumn(name = "idGrupo", referencedColumnName = "id", nullable = false)
	private AuthGrupo grupo = new AuthGrupo();

	public AuthUtilizador() {
	}

	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * @return the username
	 */
	public String getUsername() {
		return username;
	}

	/**
	 * @param username
	 *            the username to set
	 */
	public void setUsername(String username) {
		this.username = username;
	}

	/**
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * @param password
	 *            the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * @return the activo
	 */
	public boolean isActivo() {
		return activo;
	}

	/**
	 * @param activo
	 *            the activo to set
	 */
	public void setActivo(boolean activo) {
		this.activo = activo;
	}

	/**
	 * @return the nome
	 */
	public String getNome() {
		return nome;
	}

	/**
	 * @param nome
	 *            the nome to set
	 */
	public void setNome(String nome) {
		this.nome = nome;
	}

	/**
	 * @return the telefone
	 */
	public Integer getTelefone() {
		return telefone;
	}

	/**
	 * @param telefone
	 *            the telefone to set
	 */
	public void setTelefone(Integer telefone) {
		this.telefone = telefone;
	}

	/**
	 * @return the extensao
	 */
	public Integer getExtensao() {
		return extensao;
	}

	/**
	 * @param extensao
	 *            the extensao to set
	 */
	public void setExtensao(Integer extensao) {
		this.extensao = extensao;
	}

	/**
	 * @return the fax
	 */
	public Integer getFax() {
		return fax;
	}

	/**
	 * @param fax
	 *            the fax to set
	 */
	public void setFax(Integer fax) {
		this.fax = fax;
	}

	/**
	 * @return the email
	 */
	public String getEmail() {
		return email;
	}

	/**
	 * @param email
	 *            the email to set
	 */
	public void setEmail(String email) {
		this.email = email;
	}

	/**
	 * @return the dataRegisto
	 */
	public Date getDataRegisto() {
		return dataRegisto;
	}

	/**
	 * @param dataRegisto
	 *            the dataRegisto to set
	 */
	public void setDataRegisto(Date dataRegisto) {
		this.dataRegisto = dataRegisto;
	}

	/**
	 * @return the dataAlteracao
	 */
	public Date getDataAlteracao() {
		return dataAlteracao;
	}

	/**
	 * @param dataAlteracao
	 *            the dataAlteracao to set
	 */
	public void setDataAlteracao(Date dataAlteracao) {
		this.dataAlteracao = dataAlteracao;
	}

	/**
	 * @return the grupo
	 */
	public AuthGrupo getGrupo() {
		return grupo;
	}

	/**
	 * @param grupo
	 *            the grupo to set
	 */
	public void setGrupo(AuthGrupo grupo) {
		this.grupo = grupo;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		AuthUtilizador other = (AuthUtilizador) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return username + " - " + nome;
	}

}